package org.geom.curve;

import org.geom.Maths;
import org.geom.Vector3D;

public class Viviani extends Curve {

    private float a = 50;
	
	public float getA() {
		return a;
	}

	public void setA(float a) {
		this.a = a;
	}

	@Override
	public Vector3D derivateI(float t) {
		Vector3D r = new Vector3D();
		
		r.x = - a * Maths.sin(t);
		r.y =  Maths.cos(t);
		r.z = 2*a * Maths.cos( t/2 );
		
		return r;
	}

	@Override
	public Vector3D derivateII(float t) {
		Vector3D r = new Vector3D();
		
		r.x = a * Maths.cos(t);
		r.y = - Maths.sin(t);
		r.z = -2*a * Maths.sin( t/2 );
		
		return r;
	}

	@Override
	public Vector3D sample(float t) {
		Vector3D r = new Vector3D();
		
	    r.x = a*(1+Maths.cos(t));
	    r.y = a*Maths.sin(t);
	    r.z = 2*a*Maths.sin( t/2 );

	    return r;
	}

	@Override
	public float getArc() {
		float totallength = 2*Maths.TWO_PI;
		return totallength/((float)length-1);
	}

}
